//
//  CityCell.m
//  YouMin_iOS
//
//  Created by lanou3g on 15/12/11.
//  Copyright © 2015年 wey. All rights reserved.
//

#import "CityCell.h"
#import "UIImageView+WebCache.h"
@implementation CityCell

// 重写setCellModel
- (void)setCityCells:(CityCellModel *)cityCells {
    if (_cityCells != cityCells) {
        _cityCells = nil;
        _cityCells = cityCells;
        [self setNewsCellContent];
    }
}

//设置cell 的内容
- (void)setNewsCellContent {
    // 主图片
    [self.titleImage sd_setImageWithURL:[NSURL URLWithString:self.cityCells.title_page]];
    // 小图片
    [self.roundImage sd_setImageWithURL:[NSURL URLWithString:self.cityCells.avatar_l]];
    // 主标题
    self.mainTitle.text = self.cityCells.title;
    // 副标题
    NSString *str = @"  ·  ";
    NSString *str1 = [NSString stringWithFormat:@"%@%@",self.cityCells.like_count,@"人喜欢"];
    if ((self.cityCells.address.length < 10)&&(self.cityCells.address.length > 1)) {
        self.subHead.text = [NSString stringWithFormat:@"%@%@%@%@%@",self.cityCells.date_str,str,self.cityCells.address,str,str1];
    }else if (self.cityCells.address.length < 1) {
        self.subHead.text = [NSString stringWithFormat:@"%@%@%@",self.cityCells.date_str,str,str1];
    }else {
        NSString *str2 = [self.cityCells.address substringToIndex:10];
        self.subHead.text = [NSString stringWithFormat:@"%@%@%@%@%@%@",self.cityCells.date_str,str,str2,@"...",str,str1];
    }
    // 类型标签1
    self.kindField1.text = self.cityCells.tab_list[0];
    // 类型标签2
    if (self.cityCells.tab_list.count == 2) {
        self.kindField2.hidden = NO;
        self.kindField2.text = self.cityCells.tab_list[1];
    }
    if (self.cityCells.tab_list.count == 3) {
        self.kindField2.hidden = NO;
        self.kindField2.text = self.cityCells.tab_list[1];
        self.kindField3.hidden = NO;
        self.kindField3.text = self.cityCells.tab_list[2];
    }
    // 价格标签
    self.priceLabel.text = [@"￥" stringByAppendingString:self.cityCells.price];
}

@end
